/*
 * Copyright 2017-2024 noear.org and authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.dalmatian.common.translation.integration;


import org.dalmatian.common.translation.core.TranslationCache;
import org.dalmatian.common.translation.core.TranslationConfig;
import org.dalmatian.common.translation.core.TranslationServiceImpl;
import org.dalmatian.common.translation.core.impl.DeptNameTranslationImpl;
import org.dalmatian.common.translation.core.impl.DictTypeTranslationImpl;
import org.dalmatian.common.translation.core.impl.NicknameTranslationImpl;
import org.dalmatian.common.translation.core.impl.OssUrlTranslationImpl;
import org.dalmatian.common.translation.core.impl.UserNameTranslationImpl;
import org.dalmatian.common.translation.processor.TranslationResponseInterceptor;
import org.noear.solon.annotation.Mapping;
import org.noear.solon.core.AppContext;
import org.noear.solon.core.Plugin;


/**
 * @author noear
 * @since 1.7
 */
public class XPluginImp implements Plugin {

    @Override
    public void start(AppContext context) {
        context.beanScan(DeptNameTranslationImpl.class);
        context.beanScan(DictTypeTranslationImpl.class);
        context.beanScan(NicknameTranslationImpl.class);
        context.beanScan(OssUrlTranslationImpl.class);
        context.beanScan(UserNameTranslationImpl.class);
        context.beanScan(TranslationCache.class);
        context.beanScan(TranslationServiceImpl.class);
        context.beanScan(TranslationConfig.class);
        context.beanInterceptorAdd(Mapping.class,new TranslationResponseInterceptor(),1);
        //只扫描 注解带Controller 的类
//        CacheFactory cacheFactory = new RedissonCacheFactoryImpl();
//        CacheLib.cacheFactoryAdd("redis", cacheFactory);
//        CacheLib.cacheFactoryAdd("redisson", cacheFactory);
    }
}
